package com.springboot.bigevent.validation;

import com.springboot.bigevent.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
// state 将来校验的数据
// string 校验的数据格式
public class StateValidation implements ConstraintValidator<State, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        //提供校验规则
        if(value == null){
            return false;//校验不通过
        }
        if(value.equals("已发布") || value.equals("草稿")){
            return true;//校验通过
        }
        return false;
    }
}
